package com.wlc.base.method;

import com.wlc.base.scanner.ScannerDemo;

import java.util.Scanner;

/**
 * @author 王立朝 wanglichao@champion-credit.com
 * @description 递归方法
 * @date 2021-06-24 09:08
 */
public class Demo02 {
    public static void main(String[] args) {
        new Demo02().js();
    }

    /**
     * 数学题: n*(n-1)  可以利用递归的方式来解
     * 4  4*3*2*1
     * 3  3*2*1
     * 2  2*1
     * 1  1
     *
     * @param number
     */
    public int f(int number) {
        if (number == 1) {
            return 1;
        } else {
            return number * f(number - 1);
        }
    }

    public double js(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入第一个数字");
        double num1 = sc.nextDouble();
        System.out.println("请输入第二个数字");
        double num2 = sc.nextDouble();
        System.out.println("请输入计算符号");
        String type = sc.next();
        switch (type){
            case "+":
                System.out.println(add(num1, num2));
                break;
            case "-":
                System.out.println(reduce(num1, num2));
                break;
            case "*":
                System.out.println(mul(num1, num2));
                break;
            case "/":
                System.out.println(div(num1, num2));
                break;
        }
        sc.close();
        return 0.0;
    }

    /**
     * 加法
     *
     * @param a
     * @param b
     * @return
     */
    public double add(double a, double b) {
        return a + b;
    }

    /**
     * 减法
     *
     * @param a
     * @param b
     * @return
     */
    public double reduce(double a, double b) {
        return a - b;
    }

    /**
     * 乘法
     *
     * @param a
     * @param b
     * @return
     */
    public double mul(double a, double b) {
        return a * b;
    }

    /**
     * 除法
     *
     * @param a
     * @param b
     * @return
     */
    public double div(double a, double b) {
        return a / b;
    }


}
